package com.lj.back.manage.scaffold.module.sys.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lj.back.manage.scaffold.module.sys.DO.SysMenuPermDO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import javax.validation.constraints.NotNull;

/**
 * 后台管理---菜单权限dao
 * @author lv
 * @version 1.0.0
 */
@Mapper
@Repository
public interface SysMenuPermDao extends BaseMapper<SysMenuPermDO> {

    /**
     * 根据菜单ID删除菜单权限关联关系
     * @param menuId 菜单ID
     * @return
     */
    default int deleteMenuPermByMenuId(@NotNull(message = "{menu.id.notnull}") Long menuId){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("menu_id",menuId);
        return delete(queryWrapper);
    }

    /**
     * 根据权限Id删除菜单权限关联关系
     * @param permId 角色ID
     * @return
     */
    default int deleteMenuPermByPermId(@NotNull(message = "{perm.id.notnull}") Long permId){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("perm_id",permId);
        return delete(queryWrapper);
    }
}
